import 'package:flutter/material.dart';
import '../style/text.dart';

// 内容弹窗
Future<void> popupDialog(BuildContext ctx,
    {String content, String buttonText, VoidCallback onPressed}) {
  return showDialog<void>(
      context: ctx,
      builder: (_) => SimpleDialog(
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
            title: Text(
              content,
              style: mainThemeStyle,
              textAlign: TextAlign.center,
            ),
            children: <Widget>[
              SimpleDialogOption(
                child: MaterialButton(
                  onPressed: () {
                    // 如果存在可调用的方法则调用
                    if (onPressed != null) {
                      onPressed();
                    }
                    Navigator.pop(ctx);
                  }, // 弹出一个导航栈
                  child: Text(
                    buttonText,
                    style: mainThemeStyle,
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
            ],
          ));
}
